// pages/user-course/user-course-detail/course-schedule/course-schedule-signin-success/course-schedule-signin-success.js
const app = getApp()
const constant = require("../../../constant.js")
const storage = require("../../../utils/storage.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    qiniu: constant.resource.qiniu
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      roundId: options.roundId,
      //roundId: 39156,
      qiniu: constant.resource.qiniu,
      host: constant.api(app.globalData.pord).url,
      unionid: wx.getStorageSync(storage.keys.unionid)
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      url: that.data.host + '/signin/course-rounds/' + that.data.roundId + '/signin-success?unionid=' + that.data.unionid,
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        if (res.data.code == "0") {
          that.setData({
            round: res.data.data.courseRound,
            courseName: res.data.data.courseName,
            limit: res.data.data.limit,
            effectiveTime: res.data.data.effectiveTime,
            studentName: res.data.data.studentName,
            finishCount: res.data.data.finishCount,
            currentDate: res.data.data.currentDate
          });     
        }
      },
      fail: function (res) { }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})